package stat;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class Overhead {
	/**
	 * @param args
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
//		String file = "scripts/gnuplot/logs/rarest_first_overheadlog.log";
		String file = "scripts/gnuplot/logs/sliding_overheadlog.log";
//		String file = "scripts/gnuplot/logs/segment_overheadlog.log";

		Map<String, Integer> map = new HashMap<String, Integer>();
		try {
			BufferedReader br = new BufferedReader(new FileReader(file));
			String str;
			while ((str = br.readLine()) != null){
				String[] array = str.split(";");
				
				String currentPeer = array[1];
				if(!map.containsKey(currentPeer)){
					map.put(currentPeer, 1);
				} else {
					int t = map.get(currentPeer)+1;
					map.remove(currentPeer);
					map.put(currentPeer, t++);
				}
			}
		} catch(IOException e) {
		} 
		
		for(Object peer : map.keySet()) { //each peer
			System.out.println((String)peer + ": " + map.get((String)peer));
		}
	}
}
